package com.phoenix.seata.service;

import com.phoenix.seata.Entity.User;
import com.phoenix.seata.Mapper.UserRepository;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/***
 * @Auther: 汪孟飞
 * @Description:
 * @Date: 2025-05-24 15:25
 * @Copyright:
 ***/
@Service
public class UserService {

    @Autowired
    private UserRepository userRepository;

    @GlobalTransactional
    public void createUser(User user){
        userRepository.save(user);
        if(user.getName().equals("张三")){
            throw new RuntimeException("同名异常");
        }
    }
}
